package com.coin900.coin.cmd.user;

import com.coin900.coin.cmd.ACmd;
import com.coin900.coin.cmd.CmdSign;
import com.coin900.coin.code.CmdCode;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;

/**
 * 登出
 *
 * @author shui
 * @create 2018-01-04
 **/
@Controller
public class LogoutCmd extends ACmd {

    @Override
    public CmdSign execute(HttpServletRequest request, CmdSign sign) throws Exception {
        CmdSign respSign = new CmdSign(sign);
        Subject currentUser = SecurityUtils.getSubject();
        if (super.getUser(sign) != null) {
            currentUser.logout();
        }
        return respSign;
    }

    @Override
    public String getCmdCode() {
        return CmdCode.FU_LOGOUT;
    }
}
